home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / amigadoslibrary / read.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  1KB  |  48 lines

  1. /* Read.c   V1.0   93-03-15                        */
  2. /* ROM library: "dos.library/Read", (All versions) */
  3. /* Copyright 1993, Anders Bjerin, Amiga C Club     */
  4.  
  5. #include <dos/dos.h>
  6.  
  7. #include <clib/dos_protos.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. UBYTE *version = "$VER: Read 1.0";
  12.  
  13. int main( int argc, char *argv[] );
  14. int main( int argc, char *argv[] )
  15. {
  16.   BPTR my_file;
  17.   int my_data[ 5 ];
  18.   long bytes_read;
  19.  
  20.  
  21.   /* Open an old (already existing) file: */
  22.   my_file = Open( "RAM:Score.dat", MODE_OLDFILE );
  23.   if( !my_file )
  24.     exit( 20 );
  25.  
  26.   /* Read some data: */
  27.   bytes_read = Read( my_file, my_data, sizeof( my_data ) );
  28.  
  29.   /* Did we get all data? */ 
  30.   if( bytes_read != sizeof( my_data ) )
  31.   {
  32.     /* Could not collect all data!      */
  33.     /* Check if it was EOF or an Error: */
  34.     if( bytes_read == -1 )
  35.       printf( "There was an error!\n" );
  36.     else
  37.       printf( "Unexpected EOF!\n" );
  38.   }
  39.   else
  40.     printf( "All data were successfully collected!\n" );
  41.  
  42.   /* Close the file: */
  43.   Close( my_file );
  44.  
  45.   exit( 0 );
  46. }
  47.  
  48.